home *** CD-ROM | disk | FTP | other *** search
/ Amiga News 95 / Amiga News 95.iso / dpat / dpat08 / lfman / doc2hlp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-08  |  2.5 KB  |  96 lines

  1. /* SOS */
  2. /***************************************************************************
  3.  
  4.                                  Doc2Hlp
  5.                               © LF soft 1992
  6.  
  7.     Doc2Hlp can use french if you set the Lang Env-variable to "français".
  8.  
  9.     Doc2Hlp convert CSH man files to LFman file format. It can work w/
  10.     version 4.02 of CSH or plus if Shell.doc keep the same format.
  11.     (tested w/ 5.19 CSH docs file).
  12.  
  13.         Doc2Hlp is a FreeWare product of L.FAILLIE. All rights reserved.
  14.     You can't use this tools, nor LFman, on a Comercial product. You must
  15.     also get the licence of LFman if you think it's usefull. Read
  16.     the LFman doc ( LFman.aide or LFman.man ) for more informations .
  17.  
  18.  
  19.                                 L.FAILLIE
  20.                              " Les Vuardes "
  21.                              74930 Reignier
  22.                                  FRANCE
  23.  
  24.      Doc2Hlp work fine but I think you need to delete some extra ##.
  25. ***************************************************************************/
  26.  
  27.  
  28. #include <LF.h>
  29. #include <string.h>
  30. #include <stdlib.h>
  31.  
  32. volatile UBYTE  lang=0;     /* English by default */
  33. register UBYTE  fl=0;
  34.  
  35. volatile char *var;  /* Ptr on var */
  36. char l[256];
  37.  
  38. volatile const char  *cof_err[]={"Can't open file","Erreur d'ouverture"};
  39.  
  40. void error(char *msg){
  41.     printf("\033[33m%s\n\033[0m",msg);
  42. }
  43.  
  44. void main(int ac, char **av){
  45.  
  46.     FILE *src,*dst;
  47.  
  48.     if(var=getenv("Lang")){
  49.         if(!stricmp(var,"Français"))
  50.             lang=1;
  51.     }
  52.  
  53.     if(ac!=3){
  54.         error("     Doc2Hlp");
  55.         puts("    © LF 1992\n");
  56.         puts(" \33[1mSyntaxe :\33[0m\n      Doc2Hlp src dst");
  57.         switch(lang){
  58.         case 1: /* français */
  59.             puts("Convertie le fichier doc de CSH en fichier LFman");
  60.             break;
  61.         default :
  62.             puts("Make a LFman file from the CSH doc file");
  63.         }
  64.         exit(0);
  65.     }
  66.  
  67.     if(!(src=fopen(av[1],"r"))|| !(dst=fopen(av[2],"w"))){
  68.         error(cof_err[lang]);
  69.         exit(0);
  70.     }
  71.  
  72.     until(feof(src)){
  73.         LFgets(src,l,255);
  74.         if(feof(src))
  75.             break;
  76.         if(!strncmp(l,"    ",4)){
  77.             fl=0;
  78.             fprintf(dst,"##%s\n",&(l[4]));
  79.         } else if(strlen(l)==0){
  80.             if(fl){
  81.                 fprintf(dst,"##\n");
  82.                 fl=0;
  83.             } else {
  84.                 fl=1;
  85.                 fprintf(dst,"\n");
  86.             }
  87.         } else {
  88.             fl=0;
  89.             fprintf(dst,"%s\n",l);
  90.         }
  91.     }
  92.     fclose(src);
  93.     fclose(dst);
  94.     exit(0);
  95. }
  96.